package com.ysm.smfu.holder;

import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.ysm.smfu.R;
import com.ysm.smfu.bean.DetailInfo;
import com.ysm.smfu.utils.UIUtils;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2016/10/14.
 */
public class MingXiHolder extends BaseHolder<DetailInfo> {

    @BindView(R.id.mingxi_time)
    TextView mingxiTime;
    @BindView(R.id.day)
    TextView day;
    @BindView(R.id.mingxi_money)
    TextView mingxiMoney;
    @BindView(R.id.mingxi_phone)
    TextView mingxiPhone;
    @BindView(R.id.mingxi_time_d)
    TextView mingxiTimeD;

    @Override
    protected View initView() {
        View view = UIUtils.inflate(R.layout.mingxi_item);
        ButterKnife.bind(this, view);
        return view;
    }

    @Override
    protected void refreshView(DetailInfo data) {
        mingxiTime.setText(data.finishY);
        day.setText(data.finishD);
        mingxiPhone.setText("来自" + data.phone);
        mingxiTimeD.setText(data.finishH);
        double price = data.price;
        String s = String.valueOf(price).split("\\.")[1];
        if (TextUtils.equals(data.pointsNum, "0")) {
            if (s != null && s.length() == 1) {
                mingxiMoney.setText(price + "0元");
            } else {
                mingxiMoney.setText(price + "元");
            }
        } else {
            if (s != null && s.length() == 1) {
                if (price == 0.0 || price == 0)
                    mingxiMoney.setText(data.pointsNum + "兑换券");
                else
                    mingxiMoney.setText(price + "0元       " + data.pointsNum + "兑换券");
            } else
                mingxiMoney.setText(price + "元       " + data.pointsNum + "兑换券");
        }
    }
}
